/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jsurftwmm;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.Border;
import jopensurf.InterestPoint;
import jopensurf.SURFInterestPoint;
import jopensurf.Surf;
import jopensurf.SurfCompare;

/**
 *
 * @author Lukáš
 */
public class NewJFrame extends javax.swing.JFrame {

    /**
     * Creates new form NewJFrame
     */
    static private final String newline = "\n";
    private SurfImage image;
    Surf surfFirstImage;
    ArrayList<SurfImage> imagesToCompare = new ArrayList<SurfImage>();
    double matchingDistance = 0.65d;

    public NewJFrame() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        topPanel = new javax.swing.JPanel();
        pictureButton = new javax.swing.JButton();
        folderButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        log = new javax.swing.JTextArea();
        exitButton = new javax.swing.JButton();
        jSlider1 = new javax.swing.JSlider();
        SettingsPanel = new javax.swing.JLabel();
        sliderValue = new javax.swing.JLabel();
        bottomPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        resultPanelScroll = new javax.swing.JScrollPane();
        resultPanel = new javax.swing.JPanel();
        mainImagePanel = new javax.swing.JPanel();
        mainImageLabel = new javax.swing.JLabel();
        bestPicturePanel = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(110, 0, 50));

        topPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        pictureButton.setText("Pick up file");
        pictureButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pictureButtonActionPerformed(evt);
            }
        });

        folderButton.setText("Pick up folder");
        folderButton.setEnabled(false);
        folderButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                folderButtonActionPerformed(evt);
            }
        });

        log.setColumns(20);
        log.setRows(5);
        jScrollPane1.setViewportView(log);

        exitButton.setText("Exit");
        exitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonActionPerformed(evt);
            }
        });

        jSlider1.setToolTipText("");
        jSlider1.setValue(65);
        jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSlider1StateChanged(evt);
            }
        });

        SettingsPanel.setText("Distance:");

        sliderValue.setText("0.65");

        javax.swing.GroupLayout topPanelLayout = new javax.swing.GroupLayout(topPanel);
        topPanel.setLayout(topPanelLayout);
        topPanelLayout.setHorizontalGroup(
            topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(topPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(topPanelLayout.createSequentialGroup()
                        .addComponent(pictureButton)
                        .addGap(18, 18, 18)
                        .addComponent(folderButton)
                        .addGap(18, 18, 18)
                        .addComponent(exitButton))
                    .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(topPanelLayout.createSequentialGroup()
                        .addComponent(SettingsPanel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sliderValue)))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE)
                .addContainerGap())
        );
        topPanelLayout.setVerticalGroup(
            topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(topPanelLayout.createSequentialGroup()
                .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(topPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1))
                    .addGroup(topPanelLayout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(pictureButton)
                            .addComponent(folderButton)
                            .addComponent(exitButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(SettingsPanel)
                            .addComponent(sliderValue))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        bottomPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel1.setText("© 2012 by Lukáš Alexandr, Michael Drdlíček");

        javax.swing.GroupLayout bottomPanelLayout = new javax.swing.GroupLayout(bottomPanel);
        bottomPanel.setLayout(bottomPanelLayout);
        bottomPanelLayout.setHorizontalGroup(
            bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(bottomPanelLayout.createSequentialGroup()
                .addContainerGap(509, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addContainerGap())
        );
        bottomPanelLayout.setVerticalGroup(
            bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bottomPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addContainerGap())
        );

        resultPanelScroll.setBorder(javax.swing.BorderFactory.createTitledBorder("Other images"));

        resultPanel.setLayout(new java.awt.GridLayout(0, 1));
        resultPanelScroll.setViewportView(resultPanel);

        mainImagePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("The choosen image"));
        mainImagePanel.setLayout(new java.awt.BorderLayout());

        mainImageLabel.setText("No image hasn't been choosen yet");
        mainImagePanel.add(mainImageLabel, java.awt.BorderLayout.CENTER);

        bestPicturePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("The most similiar picture"));
        bestPicturePanel.setLayout(new java.awt.GridLayout(0, 1));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGap(2, 2, 2)
                .addComponent(mainImagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 509, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(resultPanelScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                    .addComponent(bestPicturePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(bestPicturePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(resultPanelScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))
            .addComponent(mainImagePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(topPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(bottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(topPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bottomPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitButtonActionPerformed

    private void pictureButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pictureButtonActionPerformed
        JFileChooser fc = new JFileChooser();
        fc.setFileFilter(new ImageFilter());
        int returnVal = fc.showOpenDialog(this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            try {
                log.append("Opening: " + file.getName() + "." + newline);
                image = new SurfImage(ImageIO.read(file), file.getName(), file.getAbsolutePath());

                log.append("Initalizing SURF library." + newline);
                surfFirstImage = new Surf(image.getImage());

                // List<InterestPoint> matchingPoint = (List<InterestPoint>) mySurf.getMatchingPoints(mySurf, false);
                log.append("Counting Matching point...." + newline);
                //image.setMatchingPoint(surfFirstImage.getMatchingPoints(surfFirstImage, true, 0.65d));
                log.append("Counting done." + newline);

                log.append("Counting free oriented interest points...." + newline);
                //image.setFreeOrientedInterestPoints(surfFirstImage.getFreeOrientedInterestPoints());
                image.setUprightInterestPoints(surfFirstImage.getUprightInterestPoints());
                log.append("Counting done." + newline);
                //Image image2 = this.scale(image.getImage(), 400, 400);
                ImageIcon image2 = new ImageIcon(scale(image.getImage(), 500, 209));
                mainImageLabel.setText("");
                mainImageLabel.setIcon((image2));
                this.folderButton.setEnabled(true);
                this.updateUI();
            } catch (IOException ex) {
                log.append("Opening: " + file.getName() + "Failed." + newline);
                ex.printStackTrace();
            }
        } else {
            log.append("Open command cancelled by user." + newline);
        }
        log.setCaretPosition(log.getDocument().getLength());
    }//GEN-LAST:event_pictureButtonActionPerformed

    private void folderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_folderButtonActionPerformed
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        fc.setMultiSelectionEnabled(true);
        fc.setCurrentDirectory(new java.io.File("X://"));
        fc.setFileFilter(new ImageFilter());
        //fc.setFileSelectionMode(JFileChooser.);
        // chooser.setDialogTitle(choosertitle);
        // fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        //
        // disable the "All files" option.
        //
        //fc.setAcceptAllFileFilterUsed(false);

        int returnVal = fc.showOpenDialog(this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File files2[] = fc.getSelectedFiles();
            File files[] = null;
            if (files2[0].isDirectory()) {
                //String cesta = files[0].getAbsolutePath();
                File dir = new File(files2[0].getPath());
                List<File> listFiles = new ArrayList<File>();
                for (File f : dir.listFiles()) {
                    String name=f.getName().toUpperCase();
                    if (name.endsWith(".JPG") || name.endsWith(".TIFF") || name.endsWith(".TIF") || name.endsWith(".GIF") || name.endsWith(".JPEG") || name.endsWith(".PNG")) {
                        listFiles.add(f);
                    }
                }
                files = listFiles.toArray(new File[listFiles.size()]);

            } else {
                files = files2;
            }
            for (File f : files) {
                System.out.println(f.getName());
            }
            log.append("Processing files from dir...." + newline);
            ThreadWithResult[] thread = new ThreadWithResult[files.length];
            List<String> textFiles = textFiles(files[0].getParent());
            int threads = 5;
            if (thread.length > threads) {
                for (int i = 0; i < threads; i++) {
                    File f = files[i];
                    thread[i] = new ThreadWithResult(f, textFiles.contains(f.getName() + ".dat"));
                    thread[i].start();
                }
                for (int i = threads; i < thread.length; i++) {
                    while (thread[i - threads].isAlive()) {
                    }
                    File f = files[i];
                    thread[i] = new ThreadWithResult(f, textFiles.contains(f.getName() + ".dat"));
                    thread[i].start();
                }
            } else {
                for (int i = 0; i < files.length; i++) {
                    File f = files[i];
                    thread[i] = new ThreadWithResult(f, textFiles.contains(f.getName() + ".dat"));
                    thread[i].start();
                }
            }



            for (int i = 0; i < thread.length; i++) {

                    while (thread[i].isAlive()) {
                    }


                    this.imagesToCompare.add(thread[i].image2);
                    //System.out.println("Counting done. " + thread[i].image2.getName() + " M: " + imagesToCompare.get(i).countMatchingPoint());
                    System.out.println("Done " + i + "/" + files.length);
                    //log.append("Counting done. " + thread[i].image2.getName() + " M: " + imagesToCompare.get(i).countMatchingPoint() + newline);
                    log.append("Done " + i + "/" + files.length + newline);
                    //log.repaint();

                    this.updateUI();


            }



            log.append("All done " + imagesToCompare.size());


            Collections.sort(imagesToCompare, new MyComparator());

            for (int i = 0; i < imagesToCompare.size(); i++) {
                System.out.println(imagesToCompare.get(i).getName() + " M: " + imagesToCompare.get(i).countMatchingPoint());
            }

            if (imagesToCompare.size() != 0) {
                setUpResultView();
            }
        } else {
            log.append("Open command cancelled by user." + newline);
        }
    }//GEN-LAST:event_folderButtonActionPerformed

    private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSlider1StateChanged
        if (!jSlider1.getValueIsAdjusting()) {
            this.bestPicturePanel.removeAll();
            this.resultPanel.removeAll();
            this.updateUI();
            this.matchingDistance = (float) jSlider1.getValue() / 100;
            this.sliderValue.setText(String.valueOf(matchingDistance));
            //System.out.println(matchingDistance);
            //imagesToCompare.removeAll(imagesToCompare);
            log.append("rematching " + jSlider1.getValue() + newline);
            for (int i = 0; i < imagesToCompare.size(); i++) {
                Surf surf = new Surf(imagesToCompare.get(i).getImage());
                imagesToCompare.get(i).setMatchingPoint(surf.getMatchingPoints(surfFirstImage, true, matchingDistance));
                imagesToCompare.get(i).setSimialirity(100 * imagesToCompare.get(i).getMatchingPoint().size() / image.getUpRighFreeOrientedInterestPoints().size());
            }
            Collections.sort(imagesToCompare, new MyComparator());
            this.setUpResultView();
        }
    }//GEN-LAST:event_jSlider1StateChanged
    List<String> textFiles(String directory) {
        List<String> textFiles = new ArrayList<String>();
        File dir = new File(directory);
        for (File file : dir.listFiles()) {
            if (file.getName().endsWith(".dat")) {
                textFiles.add(file.getName());
            }
        }
        return textFiles;
    }

    private BufferedImage scale(BufferedImage src, int w, int h) {
        int type = BufferedImage.TYPE_INT_RGB;
        BufferedImage dst = new BufferedImage(w, h, type);
        Graphics2D g2 = dst.createGraphics();
        // Fill background for scale to fit.  
        g2.setBackground(UIManager.getColor("Panel.background"));
        g2.clearRect(0, 0, w, h);
        double xScale = (double) w / src.getWidth();
        double yScale = (double) h / src.getHeight();
        // Scaling options:  
        // Scale to fit - image just fits in label.  
        double scale = Math.min(xScale, yScale);
        // Scale to fill - image just fills label.  
        //double scale = Math.max(xScale, yScale);  
        int width = (int) (scale * src.getWidth());
        int height = (int) (scale * src.getHeight());
        int x = (w - width) / 2;
        int y = (h - height) / 2;
        g2.drawImage(src, x, y, width, height, null);
        g2.dispose();
        return dst;
    }

    private void setUpResultView() {
        //this.infoLabel.setText("Selected pictures:");
        int i = 0;
        for (final SurfImage simg : imagesToCompare) {
            //JLabel imageLabel = new JLabel("<html><u>"+"(" + simg.getSimilarity() + "%) "+ simg.getName() + "</u></html>", JLabel.CENTER);
            Icon icon = new ImageIcon(scale(simg.getImage(), 50, 50));
            JLabel imageLabel = new JLabel("<html><u>" + "(" + simg.getSimilarity() + "%) " + simg.getName() + "</u></html>", icon, JLabel.CENTER);
            imageLabel.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent me) {
                    SurfCompare mySurfComp = new SurfCompare(image.getImage(), simg.getImage(),matchingDistance);
                    //mySurfComp.display();
                    JFrame f = new JFrame();
                    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    f.add(new JScrollPane(mySurfComp));
                    //f.setSize(mySurfComp.getImImageAWidth+mImageBWidth,Math.max(mImageAHeight,mImageBHeight));
                    f.setSize(image.getImage().getWidth() + simg.getImage().getWidth(), Math.max(image.getImage().getHeight(), simg.getImage().getHeight()));
                    f.setLocation(0, 0);
                    f.setVisible(true);
                }
            });
            if (i == 0) {
                this.bestPicturePanel.add(imageLabel);
            } else {
                this.resultPanel.add(imageLabel);
            }
            i++;
        }
        this.updateUI();

    }

    public class ThreadWithResult extends Thread {

        File f;
        SurfImage image2;
        boolean fileExist;

        ThreadWithResult(File f, boolean exist) {
            this.f = f;
            this.fileExist = exist;
        }

        @Override
        public void run() {
            try {
                SurfImage sImage = null;
                if (fileExist) {
                    ObjectInputStream in = new ObjectInputStream(new FileInputStream(f.getPath() + ".dat"));
                    sImage = new SurfImage(ImageIO.read(f), (String) in.readObject(), f.getAbsolutePath());
                    Surf surf = new Surf();
                    List<SURFInterestPoint> readObject =(List<SURFInterestPoint>) in.readObject();
                    sImage.setMatchingPoint(surf.getMatchingPoints(surfFirstImage, true, matchingDistance, readObject));
                    sImage.setSimialirity(100 * sImage.getMatchingPoint().size() / image.getUpRighFreeOrientedInterestPoints().size());
                    in.close();
                } else {
                    sImage = new SurfImage(ImageIO.read(f), f.getName(), f.getAbsolutePath());
                    Surf surf = new Surf(sImage.getImage());
                    sImage.setMatchingPoint(surf.getMatchingPoints(surfFirstImage, true, matchingDistance, sImage));
                    sImage.setSimialirity(100 * sImage.getMatchingPoint().size() / image.getUpRighFreeOrientedInterestPoints().size());
                }

                image2 = sImage;

                System.out.println(
                        "Image done. " + image2.getName() + " done. M: " + image2.countMatchingPoint());
                log.append(
                        "Image done. " + image2.getName() + " done. M: " + image2.countMatchingPoint() + newline);

                NewJFrame.this.revalidate();
            } catch (ClassNotFoundException ex) {
                //Logger.getLogger(WindowUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            // do something that calculates "result"  

        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel SettingsPanel;
    private javax.swing.JPanel bestPicturePanel;
    private javax.swing.JPanel bottomPanel;
    private javax.swing.JButton exitButton;
    private javax.swing.JButton folderButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSlider jSlider1;
    private javax.swing.JTextArea log;
    private javax.swing.JLabel mainImageLabel;
    private javax.swing.JPanel mainImagePanel;
    private javax.swing.JButton pictureButton;
    private javax.swing.JPanel resultPanel;
    private javax.swing.JScrollPane resultPanelScroll;
    private javax.swing.JLabel sliderValue;
    private javax.swing.JPanel topPanel;
    // End of variables declaration//GEN-END:variables

    private void updateUI() {
        this.revalidate();
    }
}
